package StudyCode.summary.myfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadUnicodeFile {

	public static void main(String[] args) {
		System.out.println(readUnicodeFile("E:/迅雷下载/test1.txt", "utf-8"));
	}

	private static String readUnicodeFile(String filePath, String encoding) {
		StringBuilder buffer = new StringBuilder();
		try {
			FileInputStream fis = new FileInputStream(filePath);
			InputStreamReader isr = new InputStreamReader(fis, encoding);
			Reader in = new BufferedReader(isr);
			int ch;
			while ((ch = in.read()) > -1) {
				buffer.append((char) ch);
			}
			in.close();
			return buffer.toString();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";
	}
}
